﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BikePartsManager
{
    class User
    {
        #region Attributes

        private int _idCounter;
        private int _id;
        private string _name;
        private string _firstName;
        private DateTime _birthday;
        private UserGender _gender;
        private string _picture;
        private List<Bike> _bikes;

        #endregion

        #region Methods

        public User()
        {
            _bikes = new List<Bike>();
            _id = -1;
            _idCounter = 0;
        }

        public int AddBike(string Brand, string Model, BikeType Type,
                            int Cyl, DateTime DateProd, DateTime DateBuy, int Insurance, int Argus, string Infos,
                             BuyType BType)
        {
            int id = _idCounter;
            _idCounter++;

            Bike b = new Bike();

            b.Id = id;
            b.Brand = Brand;
            b.Model = Model;
            b.Type = Type;
            b.Cylinder = Cyl;
            b.Production_date = DateProd;
            b.Buy_date = DateBuy;
            b.Insurance = Insurance;
            b.Argus = Argus;
            b.Infos = Infos;
            b.Buy_Type = BType;

            _bikes.Add(b);

            return id;
        }

        public void DeleteBike(int Id)
        {
            for (int it = 0; it < _bikes.Count; it++)
            {
                if (_bikes[it].Id == Id)
                {
                    _bikes.RemoveAt(it);
                    break;
                }
            }
        }

        public void ModifyBike(int BikeID, string Brand, string Model, BikeType Type,
                            int Cyl, DateTime DateProd, DateTime DateBuy, int Insurance, int Argus, string Infos,
                             BuyType BType)
        {
            for (int it = 0; it < _bikes.Count; it++)
            {
                if (_bikes[it].Id == BikeID)
                {

                    _bikes[it].Brand = Brand;
                    _bikes[it].Model = Model;
                    _bikes[it].Type = Type;
                    _bikes[it].Cylinder = Cyl;
                    _bikes[it].Production_date = DateProd;
                    _bikes[it].Buy_date = DateBuy;
                    _bikes[it].Insurance = Insurance;
                    _bikes[it].Argus = Argus;
                    _bikes[it].Infos = Infos;
                    _bikes[it].Buy_Type = BType;

                    break;
                }
            }
        }

        public List<int> GetBikes()
        {
            List<int> temp = new List<int>();

            for (int it = 0; it < _bikes.Count; it++)
                temp.Add(_bikes[it].Id);
            return temp;
        }

        public Bike GetInfosBike(int BikeID)
        {
            for (int it = 0; it < _bikes.Count; it++)
            {
                if (_bikes[it].Id == BikeID)
                    return _bikes[it];
            }
            return new Bike();
        }

        #endregion

        #region Getter & Setter

        public int Id
        {
            get { return _id; }
            set { _id = value; }
        }

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public string FirstName
        {
            get { return _firstName; }
            set { _firstName = value; }
        }

        public DateTime Birthday
        {
            get { return _birthday; }
            set { _birthday = value; }
        }


        public UserGender Gender
        {
            get { return _gender; }
            set { _gender = value; }
        }

        public string PicturePath
        {
            get { return _picture; }
            set { _picture = value; }
        }

        public List<Bike> Bikes
        {
            get { return _bikes; }
            set { _bikes = value; }
        }

        #endregion

    }
}
